package com.deng.api.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deng.api.entity.CloudProduct;
import com.deng.api.mapper.CloudProductMapper;
import com.deng.api.service.ICloudProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deng.api.vo.PageVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author deng
 * @since 2022-08-10
 */
@Service
public class CloudProductServiceImpl extends ServiceImpl<CloudProductMapper, CloudProduct> implements ICloudProductService {
    @Resource
    private CloudProductMapper cloudProductMapper;

    @Override
    public PageVO getAll(Integer page, Integer size, CloudProduct cloudProduct) {
        Page<CloudProduct> page1 = new Page<>(page,size);
        LambdaQueryWrapper<CloudProduct> wrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(cloudProduct.getProduct())){
            wrapper.eq(CloudProduct::getProduct,cloudProduct.getProduct());
        }
        return PageVO.toPageVO(cloudProductMapper.selectPage(page1,wrapper));
    }
}
